package system.util;

import net.ericaro.surfaceplotter.JSurfacePanel;
import net.ericaro.surfaceplotter.surface.ArraySurfaceModel;

import org.math.plot.Plot2DPanel;

public class PlotBuilder {

	public static Plot2DPanel build2DPlot(double[] x, double[] y, String plotDescriptions)
	{
		Plot2DPanel plot = new Plot2DPanel();
		 
		// define the legend position
		plot.addLegend("SOUTH");
 
		// add a line plot to the PlotPanel
		plot.addLinePlot(plotDescriptions, x, y);
		return plot;
	}

	public static JSurfacePanel buildFast3DPlot(double[] x, double[] y, double[][] z,
			String plotDescriptions) {
		JSurfacePanel jsp = new JSurfacePanel();
        jsp.setTitleText(plotDescriptions);
        jsp.setOpaque(true);
        ArraySurfaceModel sm = new ArraySurfaceModel();
        float[][] zf = new float[z.length][z[0].length];
        for (int i = 0; i < z.length;i++) {
			for (int j = 0; j < z[0].length;j++) {
				zf[i][j]=(float) z[i][j];
			}
		}
		sm.setValues(0f,x.length,0f,y.length,zf.length, zf, null);
		sm.setWireframeType(true);
        jsp.setModel(sm);
        return jsp;
		
	}
}
